package com.redis.data.seckillshopping.config;

import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 哲思小辉
 * @version 1.0.0
 * @ClassName DruidConfig.java
 * @Description druid配置类
 * @Param
 * @createTime 2020年03月25日 20:35:00
 */
@Configuration
public class DruidConfig {
    @Bean
    public ServletRegistrationBean druidStatViewServle() {
        ServletRegistrationBean<StatViewServlet> servletRegist = new ServletRegistrationBean<StatViewServlet>(new StatViewServlet(),
                "/druid/*");
        servletRegist.addInitParameter("allow", "127.0.0.1");
        servletRegist.addInitParameter("loginUsername", "root");
        servletRegist.addInitParameter("loginPassword", "123456");
        servletRegist.addInitParameter("resetEnable", "false");
        return servletRegist;
    }

    @Bean
    public FilterRegistrationBean druidStatFilter() {
        FilterRegistrationBean<WebStatFilter> webBean = new FilterRegistrationBean<WebStatFilter>(new WebStatFilter());
        webBean.addUrlPatterns("/*");
        webBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.css,*.ico,/druid/*");
        return webBean;

    }
}
